class Solution {
public:
    ListNode* oddEvenList(ListNode* head)
    {
        if (head == nullptr)
            return head;
        ListNode* odd = head;
        ListNode* evenhead = head->next;
        ListNode* even = evenhead;
        while (even != nullptr && even->next != nullptr)
        {
            odd->next = even->next;
            odd = odd->next;
            even->next = odd->next;
            even = even->next;
        }
        odd->next = evenhead;
        return head;
    }
};